<?
//Symbiont 0.1.8
abstract class symbiont{
    
    //Creat corrent design
    public function _check($design, $default='main', $symbiont=''){
        global $kernel;
        if($symbiont==='') $symbiont=substr(get_class($this), 4);
        $dir='symbionts/'.$symbiont;
        $folder='design/'.$kernel->site->design.'/'.$dir.'/';
        if($design&&file_exists($folder.$design.'.des.html')){
            return $dir.'/'.$design;
        }
        else{
            return $dir.'/'.$default;
        }
    }
    
    //Save symbiont status
    public function _add($symbiont=''){
        return isset($symbiont['full'])?$symbiont['full']:'';
    }
    public function _edit($symbiont_old='', $symbiont_new=''){
        return isset($symbiont_new['full'])?$symbiont_new['full']:'';
    }
    public function _delete($symbiont=''){
        return true;
    }
    
    //Change symbiont status
    public function _administrate($symbiont=''){
        global $kernel;
        $this->symbiont=isset($symbiont['full'])?$symbiont['full']:'';
        $d=new design("symbionts/administrate", $symbiont['symbiont']);
    }
    //Get simple info about widget
    public function _info($symbiont){
        return array('title'=>$symbiont['full'], 'block'=>false);
    }
    
    //Open functions
    public function ___main(){
        return;
    }
    
    //Undefined functions call the main
    public function __call($name, $arguments){
        $name=str_replace('___', '', $name);
        $args=array();
        $args[0]=$arguments[0];
        unset($arguments[0]);
        $args[1]=$name;
        $i=2;
        foreach($arguments as $val){
            $args[$i++]=$val;
        }
        call_user_func_array(array($this, '___main'), $args);
    }
    
    //Get and set values
    public function __get($var){
        return isset($this->$var)?$this->$var:'empty';
    }
    public function __set($var, $val){
        $this->$var=$val;
    }
}
?>